//-------------------------------------------------------------------------
/**
   File:   Variant.h

   Descr.: - todo -

   Author: Stefan Leihkauf
   Date:   11.08.2013
*/
//-------------------------------------------------------------------------
#ifndef VARIANT_H
#define	VARIANT_H
#include "common/types/typedef.h"

class Variant
{
public:
    enum Type {
        // invalid data type
        Invalid = 0,
        
        // POD types
        Bool,
        Char,
        UChar,
        Short,
        UShort,
        Int,
        UInt,
        Long,
        ULong,
		LongLong,
		ULongLong,
		Float,
		Double
    };
    
    /// construction
    Variant();
    Variant(const Variant& variant);
    Variant(Variant::Type type);
    
    /// construction 
    Variant(bool val);
    Variant(char val);
    Variant(unsigned char val);
    Variant(short val);
    Variant(unsigned short val);
    Variant(int val);
    Variant(unsigned int val);
    Variant(long val);
    Variant(unsigned long val);
	Variant(long long val);
	Variant(unsigned long long val);
	Variant(float val);
	Variant(double val);
    
    /// destruction
    ~Variant();
    
    /// set value
    template <typename T>
    inline void setValue(const T& value);
    
    // get type of variant
    Variant::Type getType() const;
    /// get name of type as string
    std::string getTypeName() const;
    
    /// get value
//    template <typename T>
//    T value() const;
    
    /// assignement
    Variant& operator = (const Variant& other);
    
    /// equality
    bool operator == (const Variant& other) const;
    /// inequality
    bool operator != (const Variant& other) const;
    
private:
    struct Data {
        union {
            bool _bool;
            
            char _char;
            unsigned char _uchar;
            
            short _short;
            unsigned short _ushort;
            
            int _int;
            unsigned int _uint;
            
            long _long;
            unsigned long _ulong;

			long long _longlong;
			unsigned long long _ulonglong;

			float _float;
			double _double;
        }; // POD types
    };
    
    Type _type;
    Data _data;
};
#include "Variant.hpp"
#endif	/* VARIANT_H */

